package com.yc.framework.security.context;

import com.yc.system.domain.SysLoginInfo;
import org.springframework.security.core.Authentication;

public class AuthenticationContextHolder {

    private static final ThreadLocal<Authentication> contextHolder = new ThreadLocal<>();

    private static final ThreadLocal<SysLoginInfo> contextInfo = new ThreadLocal<>();

    public static Authentication getContext() {
        return contextHolder.get();
    }

    public static void setContext(Authentication context) {
        contextHolder.set(context);
    }

    public static SysLoginInfo getInfo() {
        return contextInfo.get();
    }

    /**
     * 登录信息
     * @param sysLoginInfo
     */
    public static void setContext(SysLoginInfo sysLoginInfo) {
        contextInfo.set(sysLoginInfo);
    }

    public static void clearContext() {
        contextHolder.remove();
    }
}
